package myalert

import (
	"fmt"

	"gopkg.in/gomail.v2"
)

func SendEmail(smtpaddr, fromemail, frompassword string, sendto []string, subject, content string) {
	m := gomail.NewMessage()
	m.SetHeader("From", fromemail)
	m.SetHeader("To", sendto...)
	m.SetHeader("Subject", subject)
	m.SetBody("text/plain", content)
	d := gomail.NewDialer(smtpaddr, 465, fromemail, frompassword)
	// d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
	err := d.DialAndSend(m)
	if err != nil {
		fmt.Println(err.Error())
	} else {
		fmt.Println("send success")
	}
}
